Page({
  data: {
    user: {
      avatar: "/images/images-lxy/touxiang.jpg",
      name: "bingyou",
      bio: "个性签名或简介"
    },
    publishedContent: [
      { id: 1, imageUrl: "/images/images-lxy/发布的内容.jpg", views: 120, title: "内容标题1", likes: 12 },
      { id: 2, imageUrl: "/images/images-lxy/发布的内容.jpg", views: 85, title: "内容标题2", likes: 8 }
    ]
  },

  onLoad(options) {
    this.loadUserData();
  },

  navigateToSettings() {
    wx.navigateTo({ url: '/pages/settings/settings' });
  },

  loadUserData() {
    wx.request({
      url: 'https://api.example.com/user',
      success: res => {
        this.setData({
          user: res.data
        });
      }
    });
  },

  navigateTo(event) {
    const page = event.currentTarget.dataset.page;
    let targetUrl = '';

    switch (page) {
      case 'viewHistory':
        targetUrl = '/pages/history/history';
        break;
      case 'orders':
        targetUrl = '/pages/orders/orders';
        break;
      case 'followings':
        targetUrl = '/pages/followings/followings';
        break;
      case 'healthRecords':
        targetUrl = '/pages/healthRecords/healthRecords';
        break;
      case 'posts':
        targetUrl = '/pages/peizhen/peizhen';
        break;
      case 'settings':
        targetUrl = '/pages/settings/settings';
        break;
    }

    if (targetUrl) {
      wx.navigateTo({ url: targetUrl });
    }
  },

  navigateToLogin() {
    wx.navigateTo({ url: '/pages/login/login' });
  }
});
